Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: setInaudibleBehavior #96 #160

Merged
merged 4 commits into from
Jan 3, 2025
Merged

feat: setInaudibleBehavior #96 #160

merged 4 commits into from
Jan 3, 2025

Conversation

alnitak
Copy link
Owner

@alnitak alnitak commented Dec 21, 2024

Description

added setInaudibleBehavior. When a 3D sound is too far to be eard, you can tell flutter_soloud to kill it.

Example:

final sound = SoLoud.instance.load('path/to/sound.mp3');
final handle = SoLoud.instance.play3d(sound, 0, 0, 0);
double xPos = 0;
// set the sound to be inaudible if it's more than 10 units away
SoLoud.instance.set3dSourceMinMaxDistance(handle, 0, 10);
// set the attenuation to `LINEAR_DISTANCE` and when its position
// is 10 units away, the volume will be 0 (inaudible).
SoLoud.instance.set3dSourceAttenuation(handle, 2, 1);
// if the sound is inaudible, it will be killed and the [handle]
// becomes invalid.
SoLoud.instance.setInaudibleBehavior(handle, false, true);
// here we shift the sound position away (up to you to cancel the Timer!)
// When [xPos] reaches 10 units, the [handle] will stop.
Timer.periodic(
  const Duration(milliseconds: 100),
  (timer) {
      SoLoud.instance
          .set3dSourcePosition(handle, xPos += 0.1, 0, 0);
  },
);

Closes #96

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@alnitak alnitak merged commit 919da72 into main Jan 3, 2025
1 check passed
@alnitak alnitak deleted the inaudible_behavior branch January 3, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: Implement setInaudibleBehavior()
1 participant